function plotavbids_m2d2(dir,block,numbidders,prefs)
%Plots bids averaged over all runs
%   Detailed explanation goes here
alldata=load(strcat(dir,'\m2_n',int2str(numbidders),'_d2_',prefs,'.distr.results'));
num=length(alldata);
numexp=alldata(num,1)+1;
numruns=alldata(num,2)+1;
numblocks=alldata(num,3)+1;
avg=[numexp,4];
stdev=[numexp,4];
%block=40;
for i=1:numexp
    range=(i-1)*numblocks*numruns+block:numblocks:i*numblocks*numruns;    
    for j=1:4
        avg(i,j)=mean(alldata(range,3+j));
        stdev(i,j)=std(alldata(range,3+j));
    end;
end;
x=[0:numexp-1]./20;

clf

x0=0;
x1=3;

%a1 = x0:(x1-x0)/10:x1;


%for a1=.4
%g=1.5
lw=3;
fs=24;
d=x1/1000;

c1 = 2*(2-sqrt(2));
c2 = 2;

%ylabel('f', 'FontSize', fs);
set(gca,'FontSize',fs);
plot(x,avg(:,1),'k','LineWidth', lw,'LineStyle','--');
hold on;
plot(x,avg(:,2)+avg(:,3),'k','LineWidth', lw,'LineStyle',':');
plot(x,avg(:,4),'k','LineWidth', lw,'LineStyle','-');
xlabel('\gamma', 'FontSize', fs);

%errorbar(x,avg(:,1),stdev(:,1),'k','LineStyle','--');
%errorbar(x,avg(:,2)+avg(:,3),stdev(:,2)+stdev(:,3),'k','LineStyle',':');
%errorbar(x,avg(:,4),stdev(:,4),'k','LineStyle','-');
ylim([0 1]);
xlim([0 x(length(x))]);
%plot(x,avg(:,1),'ms','LineWidth', lw);
%hold on;
%plot(x,avg(:,2)+avg(:,3),'ro','LineWidth', lw);
%plot(x,avg(:,4),'gd','LineWidth', lw);

%if (strcmp(prefs,'id'))
 % plot([c1 c1], [0  1]);
 % plot([c2 c2], [0  1]);
  %UNTITLED2 Summary of this function goes here
  %   Detailed explanation goes here
  %plot(x,y,'LineWidth', lw);


  %text(.84*x1, .06, 'f(0,1)+f(1,0)', 'FontSize', fs)  
  %text(.93*x1, .375, 'f(0,0)', 'FontSize', fs)  
  %text(.93*x1, .63, 'f(1,1)', 'FontSize', fs)  
%fs=16;
%text(c1/2 -.3, .95, 'B'' = \{(0,0) (1,0)\}', 'FontSize', fs)  
%text(c1 + (c2-c1)/2 -.41, .95, '\{(0,0) (1,0) (1,1)\}', 'FontSize', fs)  
%text(c2 + (x1-c2)/2 -.3, .95, 'B'' = \{(0,0) (1,1)\}', 'FontSize', fs)
%else
%    plot([1 1], [0  1]);
%end;

name = strcat('./bidsm2_d2_n',int2str(numbidders),'_',prefs);
print('-depsc',strcat(name, '_nolegend.eps'));
legend('f(0,0)','f(0,1)+f(1,0)', 'f(1,1)');
print('-depsc',strcat(name, '.eps'));

hold off;
%print('-dpdf',strcat(name, '.pdf'));

end

